package com.www.applyword.ui.chat;

import android.widget.TextView;

import com.allen.library.CircleImageView;
import com.tencent.imsdk.TIMFriendshipManager;
import com.tencent.imsdk.TIMValueCallBack;
import com.tencent.imsdk.friendship.TIMFriendRequest;
import com.tencent.imsdk.friendship.TIMFriendResult;
import com.www.applyword.R;
import com.www.applyword.base.BaseActivity;
import com.www.applyword.bean.BookFriendBean;
import com.www.applyword.utils.ImageUtil;
import com.www.applyword.utils.Utils;

import butterknife.BindView;

/**
 * author : huang
 * date   : 2019/11/16 0016 15:48
 * version: 1.0
 */
public class AddFriendActivity extends BaseActivity {
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_hao)
    TextView tvHao;
    @BindView(R.id.cv_my_photo)
    CircleImageView cv_my_photo;
    private BookFriendBean bookFriendBean;


    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.add_friend_activity);
        setTitle("好友信息");
        setRringTitle("发送");

        tv_right.setOnClickListener(v -> {
            TIMFriendRequest timFriendRequest = new TIMFriendRequest(bookFriendBean.getMobile());
         //   timFriendRequest.setAddWording(mAddWording.getText().toString());
            timFriendRequest.setAddSource("android");
            TIMFriendshipManager.getInstance().addFriend(timFriendRequest, new TIMValueCallBack<TIMFriendResult>() {
                @Override
                public void onError(int i, String s) {
                    Utils.showToastSafe("Error code = " + i + ", desc = " + s);
                }

                @Override
                public void onSuccess(TIMFriendResult timFriendResult) {
                    Utils.showToastSafe("添加好友成功");
                    finish();
                }
            });
        });
    }

    @Override
    protected void loadData() {
        bookFriendBean = (BookFriendBean)getIntent().getSerializableExtra("item");
         ImageUtil.setImage(cv_my_photo, bookFriendBean.getHeadImage());
        tvName.setText(bookFriendBean.getNikeName());
        tvHao.setText(bookFriendBean.getMobile());
    }
}
